#ifndef LEAMBASICSOCKETTESTHH
#define LEAMBASICSOCKETTESTHH
#include <QDialog>
#include <QAbstractSocket>
#include <QApplication>
#include "leam-handler.hh"
#include "leam-qt-stream.hh"
#include "leam-stream.hh"

class QLabel;
class QLineEdit;
class QPushButton;
class QDialogButtonBox;
class QTcpSocket;

namespace leam 
{

    class BasicSocketTestClient : public QDialog, public ILeamHandler
    {
	Q_OBJECT
    public:
	BasicSocketTestClient(QWidget *parent, unsigned _port );
	virtual ~BasicSocketTestClient();
	//Leam Handler stuff
	virtual void handleData( TMessageId msg, LeamDataInStream& data );
	virtual void handleError( TMessageId msg
				  , const std::string& stackTrace
				  , LeamDataInStream& data );
	virtual void handleAck( TMessageId msg );
	virtual void handleFin( TMessageId msg );
	virtual void handleClose();
	
private slots:
        void sendMessage();
	void readNext();
	void displayError(QAbstractSocket::SocketError socketError);

    private:
	QLineEdit *messageLineEdit;
	QLabel *statusLabel;
	QPushButton *sendMessageButton;
	QPushButton *quitButton;
	QDialogButtonBox *buttonBox;

	QTcpSocket *tcpSocket;
	QString currentFortune;
	quint16 blockSize;
	LeamQAbstractSocketInStream inStream;
	LeamQAbstractSocketOutStream outStream;
	LeamStream leamStream;
    };
}




#endif 
